cap program drop deadualcheckupdate
program define deadualcheckupdate
version 16
global `0' done
local url1 https://gitee.com/kerrydu/deadual/raw/master
cap mata: vfile = cat(`"`url1'/`0'.ado"')
if _rc exit

mata: vfile = select(vfile,vfile:!="")
mata: vfile = usubinstr(vfile,char(9)," ",.)
mata: vfile = select(vfile,!ustrregexm(vfile,"^( )+$"))
mata: st_local("versiongit",vfile[1])
local versiongit = ustrregexrf("`versiongit'","^[\D]+","")
gettoken vers versiongit:versiongit, p(", ")
local versiongit `vers'

qui findfile `0'.ado
mata: vfile = cat("`r(fn)'")
mata: vfile = select(vfile,vfile:!="")
mata: vfile = usubinstr(vfile,char(9)," ",.)
mata: vfile = select(vfile,!ustrregexm(vfile,"^( )+$"))
mata: st_local("versionuse",vfile[1])
local versionuse = ustrregexrf("`versionuse'","^[\D]+","")
gettoken vers versionuse:versionuse, p(", ")
local versionuse `vers'	

if(`versionuse'<`versiongit'){
	di "New version available, `versionuse' =>`versiongit'"
	di "It can be updated by:"
	di "  net install deadual,from(https://gitee.com/kerrydu/deadual/raw/master) replace"
}

end